{extend name="base" /}
{block name="title"}编程资料免费下载{/block}


{block name="header"}
	{include file="public/user_header" /}
{/block}

{block name="content"}

<div class="zbd-content">
	<div class="page mt10">
		<div class="row">
			<div class="w9">
				<div class="box radius0">
					<div class="box-content">
						<div class="breadcrumb breadcrumb-zbd">
						    <a href="/" class="icon ice-home"> 首页</a>
						    <a href="/book" class="icon ice-folder-open"> 编程资源免费下载</a>
						    <a href="/book?pre_id={$bookInfo['pre']['id']}" class="icon ice-tag"> {$bookInfo['pre']['name']}</a>
						    <a href="/book?pre_id={$bookInfo['pre']['id']}&som_id={$bookInfo['som']['id']}" class="icon ice-tag"> {$bookInfo['som']['name']}</a>
						    <a href="javascript:history.go(-1);" class="back">返回</a>
						</div>

						<div class="h2 bold mb30">{$bookInfo['title']}</div>
						
						<div class="mb20">
							<span class="gray mr15">{$bookInfo['create_time']}</span>
							<span class="gray mr15">文件大小：{$bookInfo['size']}</span>
							<span class="gray mr15">{$bookInfo['yulan']} 次浏览</span>
							<span class="gray mr15">{$bookInfo['downloads_num']} 次下载</span>
						</div>

						<div class="article-detail">
							<!-- <p class="icon ice-quote fonzd blue bold"></p> -->
							<div class="miaoshu icon ice-quote ">资源来自于互联网收集或者用户上传，下载资源仅用于交流学习，请勿商用，如侵犯您的权益请联系站长删除！</div>
						</div>

						<div class="content mt30" id="content">
							{$bookInfo['content']|raw|htmlspecialchars_decode}
						</div>
						{if condition="$bookInfo['img']"}
						<div class="content mt30"><img src="{$bookInfo['img']}"></div>
						{/if}
					</div>
				</div>
			</div>
			<div class="w3">
				<div class="box radius0">
					<div class="box-content">
						<button type="button" class="btn btn-block download" id="downloads" data-book_id="{$bookInfo['id']}">点击免费下载</button>
						<div class="mt15 text-center yuanxz"><a href="javascript:;" id="link" data-link="{$bookInfo['tag_link']}">原下载地址</a></div>
					</div>
				</div>
				
				<div class="tip bg-orange tishiyude">资源来自于互联网收集或者用户上传，下载资源仅用于交流学习，请勿商用，如侵犯您的权益请联系站长删除！</div>

				<div class="box radius0">
					<div class="box-title gray icon ice-download">
						<div class="left">下载排行榜</div>
					</div>
					<div class="box-content">
						<ul class="list">
							{foreach $hotList as $key => $val}
							<li class="list-item">
								<span class="el"><span class="tag bg-co{$key+1}">{$key+1}</span><a class="ph-a" href="/book/detail?id={$val['id']}">{$val['title']}</a></span>
							</li>
							{/foreach}
						</ul>
					</div>
				</div>

			</div>
		</div>
	</div>
</div>
<!-- <img id="girlImg" src="http://www.zbd.cc/static/web/zbdui/src/img/m.png" alt=""> -->
<!-- <img id="girlImg" src="http://pic.zhengbingdong.cn/upload/20220424/0f55a5f4ac591b86951c6bc4cdc2b6d1.png" alt=""> -->
<script type="text/javascript">
	// function downloadPic () {
 //        var img = document.getElementById('girlImg'); // 获取要下载的图片
 //        var url = img.src;                            // 获取图片地址
 //        var x = new XMLHttpRequest()
 //        x.open('GET', url, true)
 //        x.responseType = 'blob'
 //        x.onload = function () {
 //                let url = window.URL.createObjectURL(x.response)
 //                let a = document.createElement('a')
 //                a.href = url
 //                a.download = 'beautifulGirl';
 //                a.click()
 //        }
 //        x.send()
	// }
	// function downloadImg(){
 //        var img = document.getElementById('girlImg'); // 获取要下载的图片
 //        var url = img.src;                            // 获取图片地址
 //        var a = document.createElement('a');          // 创建一个a节点插入的document
 //        var event = new MouseEvent('click')           // 模拟鼠标click点击事件
 //        a.download = 'beautifulGirl'                  // 设置a节点的download属性值
 //        a.href = url;                                 // 将图片的src赋值给a节点的href
 //        a.dispatchEvent(event)                        // 触发鼠标点击事件
     // }

	ice(function(){
		// downloadImg();
		ice("#downloads").click(function(e){
			var book_id = ice(this).attr('data-book_id')
			ice.ajax({
			    url:'/AjaxSyn/downBook',
			    type:'get',
			    data:{
			    	'book_id' : book_id
			    },
			    success:function(res){
			    	ui.loadClose()
			        if(res.code == 1){

			        	if(res.message=='请先登录'){
			        		ShowLogin();
			        		return false;
			        	}
			            ice.pop({content:res.message})
			            return false;
			        }else{
			        	window.open(res.data)
			        }
			    }
			});
		})

		ice("#link").click(function(e){
			var link = ice(this).attr('data-link')
			ice.prompt({
				title:'跳转外部提示',
				content: link,
				btn: ['立即跳转'],
				yes: function(d){
					window.open(link)
				}
			})
		})
	})
</script>
{/block}